package edu.hunau.cxb19.oop.class11.hk;

import java.util.Arrays;

/**
 * 玩家
 * 
 * @author hb
 *
 *         2020-03-10 15:08:45
 */
public class Player {
	private String name;
	private Poker[] pokers;

	/**
	 * 玩家拿牌
	 * 
	 * @param poker
	 */
	public void add(Poker poker) {
		if (pokers == null) {
			pokers = new Poker[0];
		}
		// 先扩容
		pokers = Arrays.copyOf(pokers, pokers.length + 1);
		pokers[pokers.length - 1] = poker;
	}

	/**
	 * @param name
	 */
	public Player(String name) {
		super();
		this.name = name;
	}

	public String toString() {
		String datas = "";
		for (int i = 0; i < pokers.length; i++) {
			datas += pokers[i].toString() + " ";
		}
		return this.name + ":" + datas;
	}

	/**
	 * 
	 */
	public Player() {
		super();
		// TODO Auto-generated constructor stub
	}

	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	}

	/**
	 * @param name the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 * @return the pokers
	 */
	public Poker[] getPokers() {
		return pokers;
	}

	/**
	 * @param pokers the pokers to set
	 */
	public void setPokers(Poker[] pokers) {
		this.pokers = pokers;
	}

}
